CASE status WHEN 'ENABLED' THEN '<div class="Healthy">Yes</div>' WHEN 'SLAVESIDE_DISABLED' THEN '<div class="Healthy">No</div>' ELSE '<div class="Warning">No</div>' END,
CASE (selectcount(*) from master.event_history where db = ev.EVENT_SCHEMA andname = ev.EVENT_NAME and errno isnullandstart >= subdate(now(), @NumDays)) WHEN0THENCONCAT('<div class="Warning">', (selectcount(*) from master.event_history where db = ev.EVENT_SCHEMA andname = ev.EVENT_NAME and errno isnullandstart >= subdate(now(), @NumDays)), '</div>') ELSE (selectcount(*) from master.event_history where db = ev.EVENT_SCHEMA andname = ev.EVENT_NAME and errno isnullandstart >= subdate(now(), @NumDays)) END,
CASE (selectcount(*) from master.event_history where db = ev.EVENT_SCHEMA andname = ev.EVENT_NAME and errno isnotnullandstart >= subdate(now(), @NumDays)) WHEN0THEN'<div class="Healthy">0</div>' ELSECONCAT('<div class="Critical">', (selectcount(*) from master.event_history where db = ev.EVENT_SCHEMA andname = ev.EVENT_NAME and errno isnotnullandstart >= subdate(now(), @NumDays)),'</div>') END,
case interval_field when "YEAR" then date_add(last_executed, interval interval_value YEAR) when "QUARTER" then date_add(last_executed, interval interval_value QUARTER) when "MONTH" then date_add(last_executed, interval interval_value MONTH) when "DAY" then date_add(last_executed, interval interval_value DAY) when "HOUR" then date_add(last_executed, interval interval_value HOUR) when "MINUTE" then date_add(last_executed, interval interval_value MINUTE) when "WEEK" then date_add(last_executed, interval interval_value WEEK) when "SECOND" then date_add(last_executed, interval interval_value SECOND) end,
(selectCASE WHEN errno isnullTHENCONCAT('<span class="Healthy">', message_text, '</span>') ELSECONCAT('<span class="Critical">', message_text, '</span>') END from master.event_history where db = ev.EVENT_SCHEMA andname = ev.EVENT_NAME orderbystartlimit1),